Skip to content

test: add pytest test suite and CI workflow#15

Open
joshbouncesecurity wants to merge 4 commits intoknostic:masterfrom
joshbouncesecurity:upstream-test-suite
Open

test: add pytest test suite and CI workflow#15
joshbouncesecurity wants to merge 4 commits intoknostic:masterfrom
joshbouncesecurity:upstream-test-suite

Conversation

@joshbouncesecurity
Copy link

Closes #13

Summary

  • Adds a pytest test suite covering parsers, token tracking, language detection, and Go CLI integration
  • Adds a GitHub Actions CI workflow that runs tests on Linux, macOS, and Windows

Tests (60 total)

Test file Tests Coverage
test_token_tracker.py 8 Pricing, cumulative tracking, reset, summaries
test_parser_adapter.py 11 Language detection (Python/JS/mixed), venv/node_modules exclusion
test_python_parser.py 19 All 4 parser phases: scanner, extractor, call graph, unit generator
test_js_parser.py 10 JS scanner, TypeScript analyzer, unit generator, full pipeline
test_go_cli.py 12 Version, help, parse commands (Python + JS), API key handling

CI workflow

Two jobs, each running on ubuntu/macos/windows (6 total):

  • python-tests: pytest suite for parsers and token tracker
  • go-tests: go vet + go build + Go CLI integration tests

Triggers on push to master and on pull requests.

Known skips on Windows

  • Unicode checkmarks in JS test_pipeline.py crash on cp1252 encoding (skipped gracefully)
  • JS parse via Go CLI skipped if system Python lacks required packages

These are pre-existing issues, not introduced by this PR.

Test plan

  • All 6 CI jobs pass on Linux, macOS, and Windows
  • Go CLI integration tests run (not skip) on all platforms
  • No changes to existing source code — tests and CI only

Do not delete the source branch until the PR has been merged. The PR depends on the branch existing in the fork.

🤖 Generated with Claude Code

joshbouncesecurity and others added 4 commits March 19, 2026 10:23
* Add pytest test suite for parsers and core utilities

Tests cover:
- TokenTracker: pricing, cumulative tracking, reset, summaries
- Parser adapter: language detection (Python/JS/mixed), venv/node_modules exclusion
- Python parser phases: scanner, function extractor, call graph builder, unit generator
- JS parser: scanner, TypeScript analyzer, unit generator, full pipeline
- Go CLI wrapper: version, help, parse commands, API key handling

Includes sample fixtures for Python and JavaScript repos.

Known xfails on Windows:
- ts-morph backslash path resolution in TypeScript analyzer
- Unicode checkmarks in JS test_pipeline.py on cp1252 encoding

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Add CI workflow to run tests on Linux, macOS, and Windows

Three jobs:
- python-tests: pytest suite (parsers + token tracker) on all 3 OSes
- go-build: go vet + go build on all 3 OSes
- go-cli-integration: Go CLI integration tests (depends on go-build)

Runs on push to master and on pull requests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ci: temporarily trigger on add-test-suite branch for testing

Will revert to master-only before merging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ci: fix warnings and run all jobs in parallel

- Remove needs dependency so go-cli-integration runs in parallel
- Add FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 to suppress deprecation warnings
- Add cache-dependency-path for Go module cache
- Revert trigger to master-only

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ci: use latest action versions instead of Node.js 24 env workaround

- checkout@v4 → v5, setup-node@v4 → v5 (both support Node.js 24)
- node-version 20 → 22
- Remove FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 env var

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ci: merge go-build and go-cli-integration into single job

Avoids duplicate checkout/setup. Also re-add FORCE_JAVASCRIPT_ACTIONS_TO_NODE24
since setup-python@v5 and setup-go@v5 don't have Node.js 24 releases yet.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* ci: remove temporary branch trigger

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use platform-aware binary name (openant.exe on Windows, openant elsewhere)
- Split CI build step per OS to produce correct binary name
- Add verification step to catch missing binary

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pre-existing issue: test_pipeline.py uses Unicode checkmarks that crash
on Windows cp1252 encoding. Will be fixed in a separate PR.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add automated test suite and CI workflow

1 participant